
<?php
/**
 * Class Controller 
 *
 * @author:Monica Lisette Dragan
 * @date: 
 */
class CategoriesController extends BaseController{

	/**
	 * Get Domain object by primry key
	 *
	 * @param String $id primary key
	 * @Return Categories 
	 */
	public function load($id){
		 $this->set("categories", $this->_model->load($id));
		
	}

        /**
         * @author: lisette 
         */
        
        
        public function bind(){
        	$catgory_ids = $this->_model->queryAll("categoryID");
        	$categories = array();
        	if (!empty($_POST['category']) || !empty($category_ids)) {
        		$categories = array_merge((array)$_POST['category'], (array)$catgory_ids);
        		$categories = array_filter(array_unique($categories));
        	}
        	return $categories;
        }
        
        
	/**
	 * Get all records from table
	 */
	public function queryAll(){
		
		set("categoriesList",$this->_model->querryAll());
		
		
	}
	
	/**
	 * Get all records from table ordered by field
	 * @Param $orderColumn column name
	 */
	public function queryAllOrderBy1($orderColumn){
		//set("categoriesList",$this->_model->queryAllOrderBy($orderColumn));
		
		
	}
	
	/**
 	 * Delete record from table
 	 * @param categorie primary key
 	 */
	public function delete($categoryID){
		
		return $this->_model->delete($categoryID);
	}
	
	/**
 	 * Insert record to table
 	 *
 	 * @param Categories categorie
 	 */
	public function insert($category){
		return $this->_model->insert($category);
	}
	
	/**
	 * Insert record in the table filecategories
	 * 
	 * @param int $file_id
	 * @param int $category_id
	 */
	public function insertFilesCategories($file_id, $category_id){
		return $this->_model->insertFilesCategories($file_id, $category_id);
	}
	
	/**
 	 * Update record in table
 	 *
 	 * @param Categories categorie
 	 */
	public function update($categoryID){
		return $this->_model->update($categoryID);
		
	}

	
	/**
	 * Delete all rows
	 */
	public function clean() {}

	public function queryByCategory($value) {}
	
	public function queryByDocument($value) {}


	public function deleteByCategory($value) {}

	/**
	 * @author: Dragan
	 */
	public function queryNumberOfChategories(){
		return $this->_model->queryNumberOfChategories();
	}
	
	/**
	 * @author: Dragan
	 * @param unknown_type $column
	 */
	public function queryAllOrderBy($column){
		return $this->_model->queryAllOrderBy($column);
	}

}
?>